/**
 * @Author fxg1997
 * @version 1.0
*/

class router {
  constructor(value, name,) {
    this.path = name
    this.name = name
    this.component = () => import( /* webpackChunkName: 'board' */'@/views/platform/ICPS/board/editBoard.vue')
    this.meta = {
      keepAlive: true,
      system: 'basicSite',
      title: value,
    }
  }

}

function Route(data) {
  let childrenArr = data.map(res => (new router(res.name, res.code)))
  let obj = [{
    path: '/pages',
    component: () => import('@/views/pages/pages.vue'),
    children: [{
      path: 'platform',
      component: () => import('@/views/platform/platform'),
      children: childrenArr
    }],
  }]
  return obj
}

const Dynamic = 'dynamicRoute';
export function getRoute() {
  return JSON.parse(window.localStorage.getItem(Dynamic))
}

export function setRoute(data) {
  let dynamicobj = Route(data)
  // console.log(dynamicobj)
  return window.localStorage.setItem(Dynamic, JSON.stringify(dynamicobj))
}

export function removeRoute() {
  return window.localStorage.removeItem(Dynamic)
}

const routeStatus = 'routeStatus'
export function getRouteStatus() {
  return JSON.parse(window.sessionStorage.getItem(routeStatus))
}

export function setRouteStatus(data) {
  return window.sessionStorage.setItem(routeStatus, JSON.stringify(data))
}

export function removeRouteStatus() {
  return window.sessionStorage.removeItem(routeStatus)
}

